package com.zsc.edu.testactivitiesintent;

import android.os.Parcel;
import android.os.Parcelable;

public class Dog implements Parcelable {
    String name = "puppy";
    int age = 1;

    // Generate   --->   Constructor
    public Dog() {
    }

    // Generate   --->   Override Methods
    @Override
    public int describeContents() {
        return 0;
    }

    // Generate   --->   Override Methods
    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(age);
        parcel.writeString(name);
    }

    // https://developer.android.google.cn/reference/android/os/Parcelable
    private Dog(Parcel in) {
        age = in.readInt();
        name = in.readString();
    }

    // https://developer.android.google.cn/reference/android/os/Parcelable
    public static final Parcelable.Creator<Dog> CREATOR
            = new Parcelable.Creator<Dog>() {
        public Dog createFromParcel(Parcel in) {
            return new Dog(in);
        }

        public Dog[] newArray(int size) {
            return new Dog[size];
        }
    };


    // Generate   --->   Getter and  Setter

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
